<%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2021-01-04
  Time: 14:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>采购申请管理</title>
    <base href="<%=request.getContextPath()%>">
    <link rel="stylesheet" href="/webjars/layui/2.5.6/css/layui.css"/>
</head>
<body>
<script type="text/html" id="toolbar">
    <div class="layui-btn-container">
<%--        <button class="layui-btn layui-btn-sm" lay-event="add">添加</button>--%>
    </div>
</script>
<table lay-filter="test" id="purchaseNote"></table>
<script type="text/html" id="action">
    <a class="layui-btn layui-btn-xs" lay-event="particulars">详情</a>
    <%--    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>--%>
</script>
<script src="/webjars/layui/2.5.6/layui.js"></script>
<script>
    layui.use(["table","jquery"],function () {
        let table=layui.table;
        let $=layui.$;
        table.render({
            id:"purchaseNote",
            elem:"#purchaseNote",
            url:"/heng/purchase/applyFor/showAll",
            height:"600px",
            toolbar: "#toolbar",
            page:true,
            limit:5,
            limits:[5,10,15,20],
            cols:[[
                {title:"编号",field:"purchaserequestMasterId"},
                {title:"申请采购单号",field:"purchaseNo"},
                {title: "申请状态",field: "state"},
                {title: "物资编码",field: "cgCode"},
                {title: "申领数量",field: "applyChildNum"}
            ]],
            done:function (res,curr,count) {
                //采购状态的转换
                $("[data-field='state']").children().each(function(){
                    if($(this).text()=='0'){
                        $(this).text("已提交")
                    }else if($(this).text()=='1'){
                        $(this).text("驳回")
                    }
                });

            }

        })

        table.on("tool(test)",function ({data,event}) {

            switch (event) {
                case "particulars":
                    update(data);
                    break;

            }
        })




    })


</script>
</body>
</html>
